package com.bwie.controller;

import com.bwie.pojo.TbType;
import com.bwie.service.TbTypeService;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/6/23 10:05
 */

@RestController
@RequestMapping("/shop/type")
public class TypeController {

    @Autowired
    TbTypeService tbTypeService;

    /**
     * @description 获取商品类型树
     * @params []
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/23 10:06
     */
    @PostMapping("/getTypeTree")
    public R getTypeTree() {
        return tbTypeService.getTypeTree();
    }

    @PostMapping("/getSelectTypeTree")
    public R getSelectTypeTree() {
        return tbTypeService.getSelectTypeTree();
    }

    /**
     * @description 添加类型
     * @params [tbType]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/23 10:52
     */
    @PostMapping("/addType")
    public R addType(@RequestBody @Validated TbType tbType) {
        return tbTypeService.addType(tbType);
    }

    /**
     * @description 商品分类图片上传
     * @params [file]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/23 11:11
     */
    @PostMapping("/uploadTypeImage")
    public R uploadTypeImage(@RequestPart("file")MultipartFile file) {
        return tbTypeService.uploadTypeImage(file);
    }

}
